def max_area(height):
    res = 0
    l, r = 0, len(height) - 1
    while l < r:
        if height[l] <= height[r]:
            res = max(res, (r - l) * height[l])
            l += 1
        else:
            res = max(res, (r - l) * height[r])
            r -= 1
    return res
